package com.lbb.utils

import android.util.DisplayMetrics


object DisplayUtil {

    fun getStatusBarHeight(): Int {
        var result = 0
        val resourceId: Int = Helper.application!!.resources.getIdentifier(
            "status_bar_height",
            "dimen",
            "android"
        )
        if (resourceId > 0) {
            result = Helper.application!!.resources.getDimensionPixelSize(resourceId)
        }
        return result
    }

    fun getScreenWidth(): Int {
        val displayMetrics: DisplayMetrics = Helper.application!!.resources.displayMetrics
        return displayMetrics.widthPixels
    }

    fun getScreenHeight(): Int {
        val displayMetrics: DisplayMetrics = Helper.application!!.resources.displayMetrics
        return displayMetrics.heightPixels
    }

    fun dp2px(dpValue: Float): Int {
        val scale: Float = Helper.application!!.resources.displayMetrics.density
        return (dpValue * scale + 0.5f).toInt()
    }

    fun sp2px(spValue: Float): Int {
        val fontScale: Float =
            Helper.application!!.resources.displayMetrics.scaledDensity
        return (spValue * fontScale + 0.5f).toInt()
    }

}